from __future__ import annotations

from dataclasses import dataclass
from math import pi


@dataclass
class BoltCheck:
    shear_capacity_kN: float
    tension_capacity_kN: float
    bearing_capacity_kN: float
    ok: bool
    note: str


def check_bolt_connection(diameter_mm: int, bolt_strength_MPa: float, plate_thickness_mm: float, hole_diameter_mm: int, design_shear_kN: float, design_tension_kN: float) -> BoltCheck:
    """螺栓抗剪、抗拉与承压承载力（简化）。"""

    import math
    A = math.pi * (diameter_mm ** 2) / 4.0
    V = 0.6 * A * bolt_strength_MPa / 1000.0
    T = 0.9 * A * bolt_strength_MPa / 1000.0
    bearing = 1.2 * plate_thickness_mm * diameter_mm * bolt_strength_MPa / 1000.0
    ok = design_shear_kN <= V and design_tension_kN <= T
    return BoltCheck(shear_capacity_kN=V, tension_capacity_kN=T, bearing_capacity_kN=bearing, ok=ok, note="需按孔边距修正")


